﻿//using Microsoft.EntityFrameworkCore;
//using Workflow2211A.Application.Services;
//using Workflow2211A.Domain;
//using Workflow2211A.Domain.Entities;
//using WorkflowCore.Interface;

//namespace Workflow2211A.API
//{
//    public static class WorkflowExtensionss
//    {

//        public static void UserWorkflow(this WebApplication app)
//        {
//            //引入工作流主机
//            var workflowHost = app.Services.GetService<IWorkflowHost>();
//            //应用程序启动时
//            app.Lifetime.ApplicationStarted.Register(() =>
//            {
//                //启动主机
//                workflowHost.Start();

//                //获取服务提供商
//                var serviceProvider = app.Services.CreateScope().ServiceProvider;
//                //获取数据库连接
//                var workflowDefinition = serviceProvider.GetService<IBaseRepository<WorkflowDefinitionModel>>();
//                //获取审批服务
//                var workflowService = serviceProvider.GetService<IWorkflowService>();
//                var workflowList = workflowDefinition.GetAll().AsNoTracking().ToList();

//                foreach (var workflow in workflowList)
//                { 
//                    workflowService.LoadDefinition(workflow);
//                }


//            });
//            //应用程序结束时
//            app.Lifetime.ApplicationStopping.Register(() =>
//            {
//                //停止主机
//                workflowHost.Stop();
//            });
//        }

//    }
//}
